package com.glp.work.flow.config.mq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 交换机和队列配置
 */
@Configuration
public class ExchangeQueueConfig {
	
    /*交换机*/
    public static final String WORK_ORDER_EXCHANGE = "work.order.exchange";
    
	/**********************债权融资平台 ************************/
    public static final String WORK_ORDER_DEBT_FINANCING_QUENE = "work.order.debt.financing.queue";
    public static final String WORK_ORDER_DEBT_FINANCING_KEY = "work.order.debt.financing.key";  
    
    /**********************车险分期*****************************/
    public static final String WORK_ORDER_INSURANCE_QUENE = "work.order.insurance.queue";
    public static final String WORK_ORDER_INSURANCE_KEY = "work.order.insurance.key";

    /**********************车险分期支付*****************************/
    public static final String WORK_ORDER_INSURANCE_PAY_QUENE = "work.order.insurance.pay.queue";
    public static final String WORK_ORDER_INSURANCE_PAY_KEY = "work.order.insurance.pay.key";
    
    /**********************CRM*****************************/
    public static final String WORK_ORDER_CRM_QUENE = "work.order.crm.queue";
    public static final String WORK_ORDER_CRM_KEY = "work.order.crm.key";

    /**********************风险预警*****************************/
    public static final String WORK_ORDER_WARNING_QUENE = "work.order.warning.queue";
    public static final String WORK_ORDER_WARNING_KEY = "work.order.warning.key";

    /**********************资产开放平台*****************************/
    public static final String WORK_ORDER_OPENAPI_QUENE = "work.order.openApi.queue";
    public static final String WORK_ORDER_OPENAPI_KEY = "work.order.openApi.key";

    /**********************统一信息视图*****************************/
    public static final String WORK_ORDER_VIEW_QUENE = "work.order.view.queue";
    public static final String WORK_ORDER_VIEW_KEY = "work.order.view.key";

    /**********************Email*****************************/
    public static final String WORK_ORDER_EMAIL_QUENE = "work.order.email.queue";
    public static final String WORK_ORDER_EMAIL_KEY = "work.order.email.key";

    /**********************合同管理系统*****************************/
    public static final String WORK_ORDER_CONTRACT_QUENE = "work.order.contract.queue";
    public static final String WORK_ORDER_CONTRACT_KEY = "work.order.contract.key";

    /**********************财资平台*****************************/
    public static final String WORK_ORDER_TREASURY_QUENE = "work.order.treasury.queue";
    public static final String WORK_ORDER_TREASURY_KEY = "work.order.treasury.key";

    /**********************监管仓*****************************/
    public static final String WORK_ORDER_WAREHOUSE_QUENE = "work.order.warehouse.queue";
    public static final String WORK_ORDER_WAREHOUSE_KEY = "work.order.warehouse.key";

    /**********************商影*****************************/
    public static final String WORK_ORDER_SHANGYING_QUENE = "work.order.shangying.queue";
    public static final String WORK_ORDER_SHANGYING_KEY = "work.order.shangying.key";

    /**********************产品中心*****************************/
    public static final String WORK_ORDER_PRODUCTCENTER_QUENE = "work.order.productCenter.queue";
    public static final String WORK_ORDER_PRODUCTCENTER_KEY = "work.order.productCenter.key";



    @Bean
    public DirectExchange exchange() {
        return new DirectExchange(WORK_ORDER_EXCHANGE, true, false);
    }
    
    /**
     * 保险分期
     */
    @Bean
    public Queue insuranceQueue() {
        return new Queue(WORK_ORDER_INSURANCE_QUENE, true);
    }
    
    @Bean
    public Binding insuranceBinding() {
        //链式写法: 用指定的路由键将队列绑定到交换机
        return BindingBuilder.bind(insuranceQueue()).to(exchange()).with(WORK_ORDER_INSURANCE_KEY);
    }

    /**
     * 车险分期支付
     */
    @Bean
    public Queue insurancePayQueue() {
        return new Queue(WORK_ORDER_INSURANCE_PAY_QUENE, true);
    }

    @Bean
    public Binding insurancePayBinding() {
        //链式写法: 用指定的路由键将队列绑定到交换机
        return BindingBuilder.bind(insurancePayQueue()).to(exchange()).with(WORK_ORDER_INSURANCE_PAY_KEY);
    }


    /**
     * 债券融资平台
     */
    @Bean
    public Queue debtFinancingQueue() {
        return new Queue(WORK_ORDER_DEBT_FINANCING_QUENE, true);
    }
    @Bean
    public Binding debtFinancingBinding() {
        //链式写法: 用指定的路由键将队列绑定到交换机
        return BindingBuilder.bind(debtFinancingQueue()).to(exchange()).with(WORK_ORDER_DEBT_FINANCING_KEY);
    }
    /**
     * CRM
     */
    @Bean
    public Queue crmQueue() {
    	return new Queue(WORK_ORDER_CRM_QUENE, true);
    }
    @Bean
    public Binding crmBinding() {
    	//链式写法: 用指定的路由键将队列绑定到交换机
    	return BindingBuilder.bind(crmQueue()).to(exchange()).with(WORK_ORDER_CRM_KEY);
    }
    /**
     * 风险预警
     */
    @Bean
    public Queue fxyjQueue() {
        return new Queue(WORK_ORDER_WARNING_QUENE, true);
    }
    @Bean
    public Binding fxyjBinding() {
        //链式写法: 用指定的路由键将队列绑定到交换机
        return BindingBuilder.bind(fxyjQueue()).to(exchange()).with(WORK_ORDER_WARNING_KEY);
    }

    /**
     * 资产开放平台
     */
    @Bean
    public Queue assetsQueue() {
        return new Queue(WORK_ORDER_OPENAPI_QUENE, true);
    }
    @Bean
    public Binding assetsBinding() {
        //链式写法: 用指定的路由键将队列绑定到交换机
        return BindingBuilder.bind(assetsQueue()).to(exchange()).with(WORK_ORDER_OPENAPI_KEY);
    }

    /**
     * 统一信息视图
     */
    @Bean
    public Queue viewQueue() {
        return new Queue(WORK_ORDER_VIEW_QUENE, true);
    }
    @Bean
    public Binding viewBinding() {
        //链式写法: 用指定的路由键将队列绑定到交换机
        return BindingBuilder.bind(viewQueue()).to(exchange()).with(WORK_ORDER_VIEW_KEY);
    }

    /**
     * Email
     */
    @Bean
    public Queue emailQueue() {
        return new Queue(WORK_ORDER_EMAIL_QUENE, true);
    }
    @Bean
    public Binding emailBinding() {
        //链式写法: 用指定的路由键将队列绑定到交换机
        return BindingBuilder.bind(emailQueue()).to(exchange()).with(WORK_ORDER_EMAIL_KEY);
    }

    /**
     * 合同管理系统
     */
    @Bean
    public Queue contractQueue() {
        return new Queue(WORK_ORDER_CONTRACT_QUENE, true);
    }
    @Bean
    public Binding contractBinding() {
        //链式写法: 用指定的路由键将队列绑定到交换机
        return BindingBuilder.bind(contractQueue()).to(exchange()).with(WORK_ORDER_CONTRACT_KEY);
    }

    /**
     * 财资平台
     */
    @Bean
    public Queue treasuryQueue() {
        return new Queue(WORK_ORDER_TREASURY_QUENE, true);
    }
    @Bean
    public Binding treasuryBinding() {
        //链式写法: 用指定的路由键将队列绑定到交换机
        return BindingBuilder.bind(treasuryQueue()).to(exchange()).with(WORK_ORDER_TREASURY_KEY);
    }

    /**
     * 监管仓
     */
    @Bean
    public Queue warehouseQueue() {
        return new Queue(WORK_ORDER_WAREHOUSE_QUENE, true);
    }
    @Bean
    public Binding warehouseBinding() {
        //链式写法: 用指定的路由键将队列绑定到交换机
        return BindingBuilder.bind(warehouseQueue()).to(exchange()).with(WORK_ORDER_WAREHOUSE_KEY);
    }


    /**
     * 商影
     */
    @Bean
    public Queue shangyingQueue() {
        return new Queue(WORK_ORDER_SHANGYING_QUENE, true);
    }
    @Bean
    public Binding shangyingBinding() {
        //链式写法: 用指定的路由键将队列绑定到交换机
        return BindingBuilder.bind(shangyingQueue()).to(exchange()).with(WORK_ORDER_SHANGYING_KEY);
    }

    /**
     * 产品中心
     */
    @Bean
    public Queue productCenterQueue() {
        return new Queue(WORK_ORDER_PRODUCTCENTER_QUENE, true);
    }
    @Bean
    public Binding productCenterBinding() {
        //链式写法: 用指定的路由键将队列绑定到交换机
        return BindingBuilder.bind(productCenterQueue()).to(exchange()).with(WORK_ORDER_PRODUCTCENTER_KEY);
    }



}
